package com.md24housecall.adapter;

import android.annotation.SuppressLint;
import android.content.Context;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.md24housecall.activity.R;

public class NavigationItemAdapter extends BaseAdapter{
	
	private Context mContext;
	private String[] title;
	
	public NavigationItemAdapter(Context context) {
		// TODO Auto-generated constructor stub
		mContext=context;
		title = context.getResources().getStringArray(R.array.left_navigation_item);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return title.length;
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return title[position];
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@SuppressLint("InflateParams")
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHolder holder=null;
        if(convertView==null) {
            convertView =LayoutInflater.from(mContext).inflate(R.layout.item_navigation,null);
            holder=new ViewHolder();
            holder.imvIcon=(ImageView)convertView.findViewById(R.id.imvIcon);
            holder.txvTitle=(TextView)convertView.findViewById(R.id.txvTitle);
            holder.lnearWrapperIcon=(LinearLayout)convertView.findViewById(R.id.wrapper_left_nav_item_icon);
            convertView.setTag(holder);
        }else{
            holder=(ViewHolder)convertView.getTag();
        }
        holder.lnearWrapperIcon.setVisibility(View.GONE);
        holder.txvTitle.setText(title[position]);
//        holder.txvTitle.setTextColor(item.getTextColor());
//        holder.txvTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP,item.getTextSize());
        return convertView;
	}

	class ViewHolder{
        ImageView imvIcon;
        TextView txvTitle;
        LinearLayout lnearWrapperIcon;
    }
}
